#include <cassert>
#include <vector>

using namespace std;

class Solution {
public:
    bool increasingTriplet(vector<int>& nums) {
        int n = nums.size();
        if (n < 3) {
            return false;
        }

        int first = nums[0], second = __INT32_MAX__;
        for (int i = 1; i < n; ++i) {
            int num = nums[i];
            if (num > second) {
                return true;
            } else if (num > first) {
                second = num;
            } else {
                first = num;
            }
        }

        return false;
    }
};

int main() {
    Solution s;

    vector<int> nums1{1, 2, 3, 4, 5};
    vector<int> nums2{5, 4, 3, 2, 1};
    vector<int> nums3{2, 1, 5, 0, 4, 6};

    assert(s.increasingTriplet(nums1) == true);
    assert(s.increasingTriplet(nums2) == false);
    assert(s.increasingTriplet(nums3) == true);

    return 0;
}